Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Feb 10, 2026

Closes phpstan/phpstan#13775

(In my understanding

Closes phpstan/phpstan#12123

(Improved later with #4873)

@staabm
Copy link
Contributor

staabm commented Feb 11, 2026

this seems to also affect phpstan/phpstan#12123 in which ondrej suggested to use a operator overloading extension.

@@ -0,0 +1,34 @@
<?php declare(strict_types = 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue 13775 also talks about array_sum which is not yet covered in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@staabm
Copy link
Contributor

staabm commented Feb 11, 2026

in phpstan/phpstan#13775 (comment) there is a php version difference mentioned. should this also be taken into account here?

Comment on lines -43 to -44
var_dump(array_sum(['5.5', false, true, new \SimpleXMLElement('<a>7.7</a>'), 5, 5.5, null]));
var_dump(array_product(['5.5', false, true, new \SimpleXMLElement('<a>7.7</a>'), 5, 5.5, null]));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't a valid usage, see
https://3v4l.org/GNJiY#v8.2.30

The SimpleXMLElement is silently ignored

@VincentLanglet VincentLanglet merged commit f2015d4 into phpstan:2.1.x Feb 11, 2026
619 of 639 checks passed
@VincentLanglet VincentLanglet deleted the fix/13775 branch February 11, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect array_sum|product array elements of castable/non-castable types GMP operations with operator overloads give false-positive errors

2 participants